dofile( "lua/SvFrame/plugin_header.lua" )

PLUGIN.Name = "Breather"
PLUGIN.Title = "Breather"
PLUGIN.Author = "bobbahbrown"
PLUGIN.Folder = "Breather"

function PLUGIN:Init()
    self:Command( "checkair", self.CheckAir )
	self:Command( "setair", self.SetAir )
end

function PLUGIN:CheckAir( ply, args )
if (not svr.CheckArg( args, 1, "string")) then return svr.ChatPrint( ply, COL_WHITE, "Syntax: /checkair <name>") end
local target = svr.PlayerByName(args[1])
if (not target) then return end
	if target:IsInWater() == false then return svr.ChatPrint( ply, COL_RED, "ERROR: Player not in water") end
	svr.ChatPrint( ply, COL_BLUE, target.Username .. "'s air is currently " .. target:GetAir())
end

function PLUGIN:SetAir( ply, args )
if (not svr.CheckArg( args, 1, "string")) then return svr.ChatPrint( ply, COL_WHITE, "Syntax: /setair <name> <number>") end
if (not svr.CheckArg( args, 2, "number")) then return svr.ChatPrint( ply, COL_WHITE, "Syntax: /setair <name> <number>") end
local target = svr.PlayerByName(args[1])
local amount = tonumber( args[2] )
if (not target) then return end
	if target:IsInWater() == true then return svr.ChatPrint( ply, COL_RED, "ERROR: Player is in water, Air not fill-able") end
	target:SetMaxAir(amount)
	svr.ChatPrint( ply, COL_BLUE, target.Username .. "'s air set to " .. amount)
end

PLUGIN:FinishLoad()